package cn.itcast.nems.common;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class BasePageRequest<T> implements Serializable {
    @JsonProperty("page_number")
    private Integer pageNumber;
    @JsonProperty("page_size")
    private Integer pageSize;
    private T condition;

    public final void convert() {
        this.setPageNumber(Objects.nonNull(this.getPageNumber()) ? this.getPageNumber() : 1);
        this.setPageSize(Objects.nonNull(this.getPageSize()) ? this.getPageSize() : 30);
    }

}
